package com.fhz.kotlinmvvm.di

import android.content.Context
import androidx.room.Room
import com.fhz.kotlinmvvm.dao.GoodsDao
import com.fhz.kotlinmvvm.utils.AppDatabase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

/**
 * 时间:2023/9/15
 * @author Mr.Feng
 * 简述: TODO
 */
@Module
@InstallIn(SingletonComponent::class)
class DaoMoudle {

    @Provides
    @Singleton
    fun providesAppDataBase(@ApplicationContext context: Context): AppDatabase{
        return Room.databaseBuilder(
            context,
            AppDatabase::class.java, "a2102"
        ).build()
    }

    @Provides
    @Singleton
    fun providesGoodsDao(appDatabase: AppDatabase) : GoodsDao{
        return appDatabase.goodsDao()
    }


}